package com.yoda.youdianda.dto;


import com.yoda.youdianda.common.ErrorResult;
import com.yoda.youdianda.common.RC;
import com.yoda.youdianda.common.ThreadContext;
import com.yoda.youdianda.domain.SysMenu;
import com.yoda.youdianda.domain.YddArticle;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;
import java.util.Objects;

@Data
public class YddArticleDto extends YddArticle{
    private String title; //标题
    private String author; //作者的用户名
    private String pic;//图片
    private String content;//文章内容
    private Integer cateid;//分类id
    private String tags;//文章的标签
    private Integer status;//文章状态 0待审核 1草稿箱 2已发布 3已删除
    private String catename;  //分类名称

    public static YddArticle init(YddArticleDto dto) {
        YddArticle yddArticle = new YddArticle();
        String id = ThreadContext.getId(RC.YDD_ID);
        BeanUtils.copyProperties(dto, yddArticle);
        yddArticle.setUserId(Integer.parseInt(id));
        yddArticle.setCreateDate(System.currentTimeMillis());
        yddArticle.setUpdateDate(System.currentTimeMillis());
        return yddArticle;
    }
}


